<?php
class Fphoto_Installer extends Engine_Package_Installer_Module
{
  function onPreinstall() {
  	$db = $this->getDb();
    $select = new Zend_Db_Select($db);
    $select->from('engine4_core_modules')
            ->where('name = ?', 'album')
            ->limit(1);
    $row = $select->query()->fetch();
   if(empty($row)){
      $base_url = Zend_Controller_Front::getInstance()->getBaseUrl();
      return $this->_error("<span style='color:red'>You have not installed the Album Plugin on your site. Please first install Album Plugin on your site and then install this Plugin.</span><br/> <a href='" . $base_url . "/manage'>Click here</a> to go to Manage Packages.");
   }
   else{
	parent::onPreinstall();
   }
  }
 public function onInstall()
  {  	
	  	$this->update();
	    parent::onInstall();
  }

  public function update(){
  	$db = $this->getDb();
  	$db->query("INSERT IGNORE INTO `engine4_core_content` (`page_id`, `type`,	`name`,	`parent_content_id`, `order`, `params`)  VALUES('1', 'widget', 'fphoto.box-photo-activity', '100', '99', '');");
  }
}
?>